#include "tamper_driver.h"
#include "public_head.h"
#include "public_macro.h"

void llcc68_sw_init(void);

void app_tamper_event_handler(app_io_evt_t *p_evt)
{
    app_io_pin_state_t pin_level = APP_IO_PIN_RESET;
    if (p_evt->arg != NULL)
    {
//        GR_LOG("%s\r\n", (char *)p_evt->arg);
    }

    if (p_evt->pin == APP_TAMPER_UP_PIN)
    {
        pin_level = app_io_read_pin(APP_IO_TYPE_NORMAL, APP_TAMPER_UP_PIN);
        if (pin_level == APP_IO_PIN_RESET)
        {
//            GR_LOG("key1 interrupt.\r\n");
            EventMask.SBP_INTERRUPT_TAMPER_PROOF_EVT = true;
        }
    }

}

void tamper_init(void)
{
    int ret = 0;
    app_io_init_t io_init = APP_IO_DEFAULT_CONFIG;

    io_init.pin  = APP_TAMPER_UP_PIN;
    io_init.mux  = APP_IO_MUX; 
    io_init.pull = APP_IO_PULLDOWN;
    io_init.mode = APP_IO_MODE_IT_RISING;
    ret = app_io_event_register_cb(APP_TAMPER_UP_IO_TYPE,&io_init, app_tamper_event_handler, 
                                   "[interrupt_io]");
    GR_LOG(" [init] key1 init %d \r\n", ret);
    
}




